import { request } from '@/util/request' // 导入 Axios 实例

// 字典查询参数
export interface DictQuery {
  pageNum: number
  pageSize: number
  dictCode?: string
  dictName?: string
  dictType?: string
  status?: number
}

// 字典视图对象
export interface DictVO {
  id: number
  dictCode: string
  dictName: string
  dictType: string
  dictValue: string
  dictLabel: string
  sort: number
  status: number
  remark: string
  createTime: string
  updateTime: string
}

// 字典表单对象
export interface DictForm {
  id?: number
  dictCode: string
  dictName: string
  dictType: string
  dictValue: string
  dictLabel: string
  sort: number
  status: number
  remark?: string
}
// 查询字典列表
export const listDict = (params: DictQuery) => {
  return request({
    url: '/virtual/dict/list',
    method: 'get',
    params,
  })
}

// 查询字典详细
export const getDict = (id: number | string) => {
  return request({
    url: `/virtual/dict/${id}`,
    method: 'get',
  })
}

// 新增字典
export const addDict = (data: DictForm) => {
  return request({
    url: '/virtual/dict',
    method: 'post',
    data,
  })
}

// 修改字典
export const updateDict = (data: DictForm) => {
  return request({
    url: '/virtual/dict',
    method: 'put',
    data,
  })
}

// 删除字典
export const deleteDict = (ids: string | number | Array<string | number>) => {
  return request({
    url: `/virtual/dict/${ids}`,
    method: 'delete',
  })
}

// 修改字典状态
export const changeDictStatus = (id: number | string, status: number) => {
  return request({
    url: `/virtual/dict/status/${id}/${status}`,
    method: 'put',
  })
}
